package com.ygqh.baby.mapper;

import com.foxinmy.weixin4j.mp.model.User;
import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.model.YgUserModel;
import com.ygqh.baby.model.YgUserRecommendModel;
import com.ygqh.baby.model.YgUserStatisticsModel;
import com.ygqh.baby.po.YgUser;
import com.ygqh.baby.po.YgUserExample;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface YgUserMapper {
	int countByExample(YgUserExample example);

	int deleteByExample(YgUserExample example);

	int deleteByPrimaryKey(Long id);

	int insert(YgUser record);

	int insertSelective(YgUser record);

	List<YgUser> selectByExample(YgUserExample example);

	YgUser selectByPrimaryKey(Long id);

	int updateByExampleSelective(@Param("record") YgUser record, @Param("example") YgUserExample example);

	int updateByExample(@Param("record") YgUser record, @Param("example") YgUserExample example);

	int updateByPrimaryKeySelective(YgUser record);

	int updateByPrimaryKey(YgUser record);

	int countSuper(@Param("phone") String phone, @Param("nickName") String nickName, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
			@Param("q") String q, @Param("fromCode") String fromCode, @Param("groupTag") String groupTag, @Param("userType") String userType);

	List<YgUser> selectSuper(@Param("queryInfo") QueryInfo queryInfo, @Param("phone") String phone, @Param("nickName") String nickName,
			@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("q") String q, @Param("fromCode") String fromCode,
			@Param("groupTag") String groupTag, @Param("userType") String userType);

	List<YgUserStatisticsModel> selectUserStatistics(@Param("queryInfo") QueryInfo queryInfo, @Param("startDate") Date startDate,
			@Param("endDate") Date endDate, @Param("sourceCode") String sourceCode, @Param("q") String q);

	int countUserStatistics(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("sourceCode") String sourceCode, @Param("q") String q);

	YgUserModel selectUserInfo(@Param("userId") Long userId);

	List<YgUserStatisticsModel> selectUserGrouBySourceCode(@Param("sourceCode") String sourceCode);

	List<Map<String, Object>> selectUserStatisticsLM(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
			@Param("sourceCode") String sourceCode);

	Boolean isGuide(@Param("userId") Long userId);

	void updateGuide(@Param("userId") Long userId);

	int isNewCustom(@Param("userId") Long userId, @Param("platformNo") String platformNo,
					@Param("startTime") Date startTime);

	Long findPaidUsersCount(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

	Long findPaidNewUsersCount(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

	int repairUnionIdBatch(@Param("users") List<User> users);

	List<String> findOpenIds(@Param("start") Long start, @Param("end") Long end);

	List<YgUser> findUsersByUserNames(@Param("usernames") List<String> usernames);

	int selectUserRecommendCount(@Param("fromCode") String fromCode, @Param("groupTag") String groupTag);

	List<YgUserRecommendModel> selectUserRecommend(@Param("queryInfo") QueryInfo queryInfo, @Param("fromCode") String fromCode,
			@Param("groupTag") String groupTag);

	List<YgUser> selectOpenIdByCouponIdList(@Param("queryInfo") QueryInfo queryInfo, @Param("couponId") Long couponId);

	int selectOpenIdByCouponIdCount(@Param("couponId") Long couponId);

	int updateSubscribeStatus(@Param("openId") String openId, @Param("isSubscribe") Boolean isSubscribe);

	int updateSubscribeStatusBatch(@Param("openIds") List<String> openIds, @Param("isSubscribe") boolean isSubscribe);

	YgUser selectLastUser();

	List<YgUser> send11buquan(@Param("isSubscribe") Boolean isSubscribe);

	int updateAgentToCancel(@Param("id") Long id);

	int isNewCustomExcludeOrderId(@Param("userId") Long userId, @Param("orderId") Long orderId);

	YgUser selectOpenId(@Param("userId") Long userId);
	List<YgUser> selectNewUserList(@Param("startDate") Date startDate);
	
	List<YgUser> selectOpenIdsByUnUsedCouponId(@Param("list") List<Long> couponIdList, @Param("createStartTime") Date createStartTime);

	List<YgUser> selectOpenIdByNotOrderWithOrderTime(@Param("startDate") Date startDate);

	List<YgUser> selectOpenIdByNotOrderWithRegisterTime(@Param("startDate") Date startDate);

	List<YgUser> selectWithField(@Param("field") String field, @Param("level")Integer level,
								 @Param("onlyNew") boolean onlyNew, @Param("isSubscribe") boolean isSubscribe,
								 @Param("hasOpenId") boolean hasOpenId, @Param("startDate") Date startDate,
								 @Param("userType") String[] userType);

	List<YgUser> selectOpenIds(@Param("idList") List<Long> idList);

	List<String> selectOpenIdByNotRegister();

}
